<?php

//自动加载模型
class Autoload_model extends Model {

	function Autoload_model()
	{
		parent::Model();	
		$this->load->model("accounts_model", "am");
		$this->load->model("fresh_model");
	}
	
	//输出公共header
	function output_header($pagedata = array())
	{
		if(!isset($pagedata["title"])) $pagedata["title"] = "热闹网 | 史上最灵活的兴趣空间";
		if(!isset($pagedata["keywords"])) $pagedata["keywords"] = "热闹、renao、热闹网、renao100、热闹100、轻站、轻、网站、轻型网站、维基、小站、兴趣、专页、博客、社区、空间、互动";
		if(!isset($pagedata["description"])) $pagedata["description"] = "热闹网(renao100.com) - 让每个人拥有史上最灵活的兴趣空间。为自己喜欢的事物建立轻型网站，并允许维基创建内容。";
		
		//登陆状态检测
		$account = $this->am->get_account();
		isset($pagedata["topmenuid"]) ? $topmenuid =  $pagedata["topmenuid"] : $topmenuid = 0;
		$viewdata["pagedata"] = $pagedata;
		$viewdata["account"] = $account;
		$viewdata["topmenuid"] = $topmenuid;
		header("Content-Type:text/html;charset=utf-8");
		$this->load->view("common/header", $viewdata);
	}
	
	//输出公共footer
	function output_footer()
	{
		$this->load->view("common/footer");
	}
	
	//添加新鲜事
	/*
	//数据格式
	$data = array(
		'typeid' => 1,//显示类型 1：站logo+标题
		'title' => p("title"),
		'userid' => $this->userid,
		'username' => $this->userinfo['username'],
		'userphoto' => $this->userinfo['photo'],
		'siteid' => $this->site['id'],
		'sitename' => $this->site['name'],
		'sitelogo' => $this->site['info']['logo'],
		'action' => 'add',
		'link' => '/site/'.$this->site['domain'].'/show/'.$this->moduleid.'/'.$result,
		'addtime' => time(),
	);*/
	function add_fresh($moduleid, $data = array())
	{
		$data["typeid"] = $this->fresh_model->get_type($moduleid);
		$data["typestr"] = $this->fresh_model->get_typestr($moduleid);
		$this->fresh_model->add($data);
	}
	
	//获取新鲜事列表
	function get_fresh($userid = 0)
	{
		if(!$userid || $userid == 0) return false;
		$lists = $this->fresh_model->lists($userid);
		return $lists;
	}
}

/* End of file */